import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

import net.Client;

public class Server {

    private Server() {
        try {
            ServerSocket server = new ServerSocket(8888);
            System.out.println("服务器开启...");

            while (true) {
                System.out.println("等待客户端连接...");
                Socket socket = server.accept();
                System.out.println("IP地址为：" + socket.getInetAddress().getHostAddress() + "的用户打开了客户端");
                Client client = new Client(socket);
                client.receiveMessage();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new Server();
    }
}